<?php    
    $id = 0;     
    if ( !empty($_GET['id'])) {
        $id = $_REQUEST['id'];
    }
    if ( !empty($_POST)) {
        // keep track post values
        $id = $_POST['id'];
         
        // delete data
        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "DELETE FROM usuarios WHERE id = ?";
        $q = $pdo->prepare($sql);
        $q->execute(array($id));
        Database::disconnect();
            echo '
                <script language>
                    $(function(){
                        alerta("Usuário deletado!");
                    }); 
                </script>;
            ';
            echo "<meta HTTP-EQUIV='Refresh' CONTENT='1;URL=usuarios'>";
         
    }
        //exibe dados sem loop
        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "SELECT * FROM usuarios where id = ?";
        $q = $pdo->prepare($sql);
        $q->execute(array($id));
        $data = $q->fetch(PDO::FETCH_ASSOC);
        $nome = $data['nome'];
        Database::disconnect();
?>
    <div id="page-wrapper">
        <div class="row">
          <div class="col-lg-12">
            <h1><i class="fa fa-users"></i> <?php echo $ssusuarios ?></h1>
            <ol class="breadcrumb">
              <li><a href="usuarios"><i class="icon-dashboard"></i> <?php echo $ssusuarios ?></a></li>
              <li class="active"><i class="icon-dashboard"></i> Deletar <?php echo $ssusuarios ?></li>
            </ol>                                    
          </div>
        </div><!-- /.row -->
      
            <div class="alert alert-dismissable alert-danger" style="text-align:center">
                <form class="form-horizontal" action="usuarios-del" method="post">
                    <input type="hidden" name="id" value="<?php echo $id;?>"/>                  
                    <p style="font-size:16px; color: #000">Tem certeza que deseja apagar o usuário: <b><?php echo $nome;?></b></p> 
                    <p><button type="submit" class="btn btn-danger">Sim, confirmar a exclusão!</button></p>
                    <p><a class="btn btn-primary" href="javascript:history.back()">Não, desejo voltar!</a></p>
                </form>
            </div>
        
        
        

      </div><!-- /#page-wrapper -->

    </div><!-- /#wrapper --> 